1. Technical Field
The present invention relates in general to computer operating systems, diagnostics software and device drivers. In particular, this invention relates to a method and system for controlling device interface behavior based on registering a thread type when a device service thread is constructed.
2. Description of the Related Art
Software designed to communicate with peripheral devices within a computer system typically is unique to each peripheral device. Due to variations in the hardware, it is often impractical to design a single program or device driver that can communicate with more than one peripheral device, unless the peripheral devices are very similar to each other. Additionally, peripheral device oriented software is often developed for an initial product design and when a new design is produced later, it is difficult to modify the software to accommodate the new architecture, which can be completely incompatible with existing software.
Another feature of peripheral device oriented software is that it tends to have a high degree of layering. Calls are deeply nested, especially when implemented in object oriented programming languages, in which methods are inherited from more generic objects and modified in the more specific objects that implement hardware interfaces.
At the bottom of xe2x80x9cdeepxe2x80x9d function calls or method xe2x80x9cstacksxe2x80x9d, the hardware interface routines perform the actual communication with the peripheral device. When a given peripheral device stack must interface with more than one peripheral device, and the peripheral devices are of greatly different interface types, information that is needed for each of the different peripheral devices must still be made available to the lowest level interface routines.
One method for passing this information is to add all the needed information to the parameter lists for the function calls. Parameter passing leads to long parameter lists containing information that may be unneeded for a specific peripheral device. However, parameter passing also wastes stack space, as the information may be stored on the stack for each level of call, depending on the level of optimization used by the compiler.
An alternative technique is passing a pointer to a structure that contains most of the information needed by the peripheral device interface routines. Structure based data passing requires careful attention to the structure form and data types. Misinterpretation of the data may occur if the structure types and data alignment are not correct. An error may require extra debugging effort.
A second alternative is the use of global data. However, globalizing data requires control of the synchronization of routines that modify and read the data, as the data is shared by all processes and all threads for which the data is visible.
Therefore, it would be desirable to provide a method for passing data to low level peripheral device interface routines without parameter passing, structure maintenance, or globalization of the data.
The objectives of providing a method and system for passing information to a low level peripheral device interface is accomplished in a method and system for controlling peripheral device interface behavior using thread registration.
The method constructs a thread for servicing the peripheral device and registers a thread identifier associated with the thread and the peripheral device information associated with the peripheral device in a thread registry. Then communication is initiated with the peripheral device from the thread, and the thread retrieves the peripheral device information by obtaining a current thread identifier and accessing the thread registry using the current thread identifier. The thread then communicates with the peripheral device using the retrieved peripheral device information.
The method may be further embodied in a computer program product adapted for use with a computer system having program instructions for carrying out the steps of the method.
The above-mentioned objectives can also be achieved in a computer system that includes multiple peripheral devices for which diagnostic or control functions are required, means for constructing a thread for servicing one of the peripheral devices, means for communicating with the peripheral device using peripheral device information. The construction means registers a thread identifier associated with the thread and peripheral device information associated with the peripheral device in a thread registry. The communication means retrieves the appropriate peripheral device information by obtaining a current thread identifier, and using the current thread identifier to retrieve the peripheral device information. The communication means then communicates with the peripheral device using the retrieved peripheral device information.
All objects, features, and advantages of the present invention will become apparent in the following detailed written description.